/**
 * 报表设计公司(2011)
 */
package com.reportgear.designer.action.report;

import java.util.EventObject;

import net.abbp.report.model.ReportModel;
import net.abbp.report.view.GridView;

import com.reportgear.core.swing.pane.base.JBaseDialog;
import net.abbp.swing.util.ImageUtils;
import com.reportgear.designer.action.StyleAction;
import com.reportgear.designer.pane.headerfooter.HeaderFooterPane;
import com.reportgear.report.setting.ReportSettings;

/**
 * 报表页眉
 * 
 * @version 1.0 2011-3-24
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since ANNCSR 2.0
 */
public class ReportHeaderAction extends StyleAction {

	public ReportHeaderAction() {
		setName("报表页眉");
		setMnemonic('H');
		setSmallIcon(ImageUtils.readIcon("report/header.png"));
	}

	@Override
	public boolean executeAction(EventObject evt) {
	    GridView workSheet = this.getGridView();

		if (workSheet == null) {
			return false;
		}

		HeaderFooterPane hfp = new HeaderFooterPane();
		hfp.setEditHeader(true);

		ReportModel model = workSheet.getReportModel();
		ReportSettings reportSettings = model.getReportSettings();

		hfp.populate(reportSettings.getHeader());
		if (hfp.showInDialog(workSheet) == JBaseDialog.RESULT_OK) {
			reportSettings.setHeader(hfp.update());

			return true;
		}

		return false;
	}

}
